package com.oracle.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;



@Controller
@RequestMapping("/Index")
public class IndexController
{
    @RequestMapping(value = "/Main",method = RequestMethod.GET)
    public String main(){
        return "Main";
    }


    @RequestMapping(value = "/Employee",method = RequestMethod.GET)
    public String employeeInfo(){
        return "EmployeeInfo";
    }

    @RequestMapping(value = "/AddEmployee",method = RequestMethod.GET)
    public String addEmployeeInfo(){
        return "AddEmployee";
    }

    @RequestMapping(value = "/EditEmployee",method = RequestMethod.GET)
    public String editEmployee(@RequestParam("data" ) String data, Model model){
        JSONArray jsonArray = JSON.parseArray(data);
        JSONObject jsonObject = jsonArray.getJSONObject(0);
        model.addAttribute("data",jsonObject);
        return "EditEmployee";
    }

    @RequestMapping(value = "/Sale",method = RequestMethod.GET)
    public String saleInfo(){return "SaleInfo";}

    @RequestMapping(value = "/DetailSaleInfo",method = RequestMethod.GET)
    public String detailSaleInfo(@RequestParam("data" ) String data, Model model)
    {
        JSONObject jsonObject = JSON.parseObject(data);
        model.addAttribute("data",jsonObject);
        return "DetailSaleInfo";
    }

    @RequestMapping(value = "/AddSale",method = RequestMethod.GET)
    public String addSale(){return "AddSale";}



    @RequestMapping(value = "/Department",method = RequestMethod.GET)
    public String departmentInfo(){
        return "DepartmentInfo";
    }

    @RequestMapping(value = "/AddDepartment",method = RequestMethod.GET)
    public String addDepartment(){
        return "AddDepartment";
    }


    @RequestMapping(value = "/EditDepartment",method = RequestMethod.GET)
    public String editDepartment(@RequestParam("data" ) String data, Model model){
        JSONArray jsonArray = JSON.parseArray(data);
        JSONObject jsonObject = jsonArray.getJSONObject(0);
        model.addAttribute("data",jsonObject);
        return "EditDepartment";
    }


    @RequestMapping(value = "/Goods",method = RequestMethod.GET)
    public String goodsInfo(){return "GoodsInfo";}

    @RequestMapping(value = "/AddGoods",method = RequestMethod.GET)
    public String addGoods(){
        return "AddGoods";
    }


    @RequestMapping(value = "/EditGoods",method = RequestMethod.GET)
    public String editGoods(@RequestParam("data" ) String data, Model model){
        JSONArray jsonArray = JSON.parseArray(data);
        JSONObject jsonObject = jsonArray.getJSONObject(0);
        model.addAttribute("data",jsonObject);
        return "EditGoods";
    }
    @RequestMapping(value = "/Supplier",method = RequestMethod.GET)
    public String supplierInfo(){return "SupplierInfo";}


    @RequestMapping(value = "/Warehouse",method = RequestMethod.GET)
    public String warehouseInfo(){return "WarehouseInfo";}

    @RequestMapping(value = "/Store",method = RequestMethod.GET)
    public String storeInfo(){return "StoreInfo";}

    @RequestMapping(value = "/DetailStoreInfo",method = RequestMethod.GET)
    public String detailStoreInfo(@RequestParam("data" ) String data, Model model){

        JSONObject jsonObject = JSON.parseObject(data);
        model.addAttribute("data",jsonObject);
        return "DetailStoreInfo";
    }

    @RequestMapping(value = "/AddStore",method = RequestMethod.GET)
    public String addStore(){return "AddStore";}




}